package com.itheima.myreflect2.Student.mythreadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @program: Myset
 * @description:
 * @author: xuejingjing
 * @create: 2021-06-20 00:46
 **/

//static  ExecutorService new FixedThreadPool(int xThreadss)
//创建一个指定最多线程数量的线程池
public class MyThreadPooDemo2 {
    public static void main(String[] args) {

        //参数不是初始值，而是最大值
        ExecutorService  executorService = Executors.newFixedThreadPool(10);

        //这句话啥意思？
        ThreadPoolExecutor pool = (ThreadPoolExecutor)executorService;

        //第一个线程
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"在执行了。。。");
        });

        //第2个线程
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"在执行了。。。");
        });

        System.out.println(pool.getPoolSize());
        //关闭线程池
        executorService.shutdown();

    }
}
